package com.company.project.core;

import java.util.Collection;

import com.github.pagehelper.Page;

public class PageInfo {

	private int code;

	private String msg;

	private int count;

	private Object data;

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public PageInfo(Object data) {
		this.code=0;
		this.msg="";
		if (data != null) {
			if (data instanceof Page) {
				Page page = (Page) data;
				this.count = (int) page.getTotal();
				this.data = page.getResult();
			}
			else if (data instanceof Collection) {
				Collection collection = (Collection) data;
				this.count = collection.size();
				this.data = data;
			}
			
		}
	}
	
	
}
